package com.fr.data.util.function;

import com.fr.base.FComparator;
import com.fr.data.util.DefaultComparator;

public class MaxFunction extends AbstractDataFunction
{
  private FComparator comparator;
  private Object maxResult;

  public MaxFunction()
  {
    this(null);
  }

  public MaxFunction(FComparator paramFComparator)
  {
    this.comparator = null;
    this.maxResult = new Double(4.9E-324D);
    if (paramFComparator == null)
      paramFComparator = new DefaultComparator();
    setComparator(paramFComparator);
    reset();
  }

  public FComparator getComparator()
  {
    return this.comparator;
  }

  public void setComparator(FComparator paramFComparator)
  {
    this.comparator = paramFComparator;
  }

  public void reset()
  {
    this.maxResult = null;
  }

  public void addData(Object paramObject)
  {
    if (paramObject == null)
      return;
    if (this.maxResult == null)
    {
      this.maxResult = paramObject;
      return;
    }
    int i = this.comparator.compare(this.maxResult, paramObject);
    if (i < 0)
      this.maxResult = paramObject;
  }

  public Object getResult()
  {
    return this.maxResult;
  }

  public String getFormula()
  {
    return "max";
  }
}